package com.Limiter;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @Package: com.Limiter
 * @ClassName: Main
 * @Author: h2cloud
 * @CreateTime: 2024/3/16 9:36 下午
 * @Description:
 */
@Slf4j
public class Main {
	public static void main(String[] args) throws InterruptedException {
		// FixedWindowRateLimiter limiter = new FixedWindowRateLimiter(1000L, 5);
		// for (int i = 0; i < 100; i++) {
		// 	if (limiter.tryAcquire()) {
		// 		log.info("执行任务");
		// 	} else {
		// 		log.info("被限流");
		// 		TimeUnit.MILLISECONDS.sleep(300);
		// 	}
		// }
		int shardId = 0;
		int shardNum = 10;
		System.out.println((++shardId) % shardNum);
	}
}

